package com.lanou.util;

import com.lanou.bean.Blog;
import org.apache.lucene.document.*;


/**
 * Created by dllo on 18/4/8.
 */
public class BlogUtils {
    public static Document blogToDocument(Blog blog) {
        Document document = new Document();
        StringField idfield = new StringField("id", String.valueOf(blog.getId()), Field.Store.YES);
        TextField titlefield = new TextField("title", blog.getTitle(), Field.Store.YES);
        TextField descfield = new TextField("desc", blog.getDesc(), Field.Store.YES);
        TextField contentfield = new TextField("content", blog.getContent(), Field.Store.YES);

        document.add(idfield);
        document.add(titlefield);
        document.add(descfield);
        document.add(contentfield);

        return document;
    }
}
